package com.xhd.db;

import com.xhd.base.log.Log;
import com.xhd.base.log.LogFactory;

public class DaoMonitor {
	  private ThreadLocal MonitorThread = new ThreadLocal();
	  private static final int jm559 = 1;
	  private static final int jm560 = 2;
	  private static final int jm561 = 3;
	  private static final Log logins;
	  private static DaoMonitor DaoInstance;
	  static Class clasIns;

	  static
	  {
	    Class tmp3_0 = clasIns;
	    if (tmp3_0 == null)
	    {
	    
	      try
	      {
	         DaoMonitor.clasIns = Class.forName("com.sinocc.systemdbmanager.DaoMonitor");
	      }
	      catch (ClassNotFoundException localClassNotFoundException)
	      {
	        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
	      }
	    }
	    logins = LogFactory.getLog(tmp3_0);
	  }

	  public static synchronized DaoMonitor getInstance()
	  {
	    if (DaoInstance == null)
	    	DaoInstance = new DaoMonitor();
	     return DaoInstance;
	  }

	  public int counterVal()
	  {
	    Integer localInteger = (Integer)this.MonitorThread.get();
	    if (localInteger != null)
	      return localInteger.intValue();
	    return 0;
	  }

	  public void counterAdd()
	  {
	    setcount(1);
	  }

	  public void counterSub()
	  {
	    setcount(2);
	  }

	  public void counterReset()
	  {
	    setcount(3);
	  }

	  private synchronized void setcount(int paramInt)
	  {
	    Integer localInteger = (Integer)this.MonitorThread.get();
	    int i = 0;
	    if (localInteger != null)
	      i = localInteger.intValue();
	    if (1 == paramInt)
	      if (++i > 9)
	        logins.warn("Thread " + Thread.currentThread().getName() + " Use too data connection: " + i);
	    else if (2 == paramInt)
	      --i;
	    else
	      i = 0;
	    this.MonitorThread.set(new Integer(i));
	  }
}
